<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/static/plugins/layui/css/layui.css">
    <script type="text/javascript" src="__PUBLIC__/static/plugins/layui/layui.js"></script>
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="shortcut icon" href="/favicon.ico" type="favicon">
    <title>桃苑管理后台</title>
    <style type="text/css">
        .header{width:100%;height: 50px;line-height: 50px;background: #2e6da4;color:#ffffff;}
        .title{margin-left: 20px;font-size: 20px;}
        .userinfo{float: right;margin-right: 10px;}
        .userinfo a{color:#ffffff;}
        .menu{width: 200px;background: #333744;position: absolute;}
        .main{position: absolute;left: 200px;right: 0px;}
        .layui-collapse{border: none;}
        .layui-colla-item{border-top: none;}
        .layui-colla-title{background: #42485b;color:#ffffff;}
        .layui-colla-content{border-top: none;padding: 0px;}
    </style>
</head>
<body>
    <div id="time" style="position: fixed;bottom: 10px;right: 10px"></div>
    <script>
        function getDateDemo(){
            /*
                //声明时间
                var date = new Date();
                alert(date);//当前时间
                alert(date.toLocaleString());//转化为本地时间
                alert(date.getFullYear());//显示年份
                alert(date.getMonth() + 1);//显示月份 0-11，需要加1
                alert(date.getDate());//显示一月中的日期
                alert(date.getDay());//显示一周的日期，星期几
                alert(date.getHours());//获取小时时间
                alert(date.getMinutes());//获取当前分钟
                alert(date.getSeconds());//获取当前秒数
                alert(date.getMilliseconds());//获取当前的毫秒数
                alert(date.getTime());//获取从1970年1月1日午夜零时，到当前时间的毫秒值
            */
            //分别获取年、月、日、时、分、秒
            var myDate = new Date();
            var year = myDate.getFullYear();
            var month = myDate.getMonth() + 1;
            var date = myDate.getDate();
            var hours = myDate.getHours();
            var minutes = myDate.getMinutes();
            var seconds = myDate.getSeconds();
            //月份的显示为两位数字如09月
            if(month < 10 ){
                month = "0" + month;
            }
            if(date < 10 ){
                date = "0" + date;
            }
            //时间拼接
            var dateTime = year + "年" + month + "月" + date + "日" + hours + "时" + minutes + "分" + seconds + "秒";
            //document.write(dateTime);//打印当前时间
            var divNode = document.getElementById("time");
            divNode.innerHTML = dateTime;
        }
        window.setInterval("getDateDemo()",1000);//每隔1秒，调用一次getDateDemo()
    </script>
    <div class="header">
        <span class="title"><span style="font-size: 20px;">{$site.values}</span>--后台管理系统</span>
        <span class="userinfo">{$admin.truename}【{$role.title}】【{$ip}】<span><a href="javascript:;" onclick="logout()">退出</a></span></span>
    </div>
    <!--菜单-->
    <div class="menu" id="menu">
        <div class="layui-collapse" lay-accordion>
            <!--{volist name="menus" id="vo"}-->
            <!--<div class="layui-colla-item">-->
                <!--<h2 class="layui-colla-title">{$vo.title}</h2>-->
                <!--<div class="layui-colla-content{$i==1?' layui-show':''}">-->
                    <!--<?php if(isset($vo['children']) && $vo['children']){?>-->
                    <!--<ul class="layui-nav layui-nav-tree" lay-filter="test">-->
                        <!--{volist name="vo.children" id="cvo"}-->
                        <!--<?php if(isset($cvo['children']) && $cvo['children']){?>-->
                                <!--<div class="layui-colla-item">-->
                                    <!--<h2 class="layui-colla-title">{$cvo.title}</h2>-->
                                    <!--<div class="layui-colla-content{$i==2?' layui-show':''}">-->
                                        <!--<ul class="layui-nav layui-nav-tree" lay-filter="test">-->
                                            <!--{volist name="cvo.children" id="cvoo"}-->
                                            <!--<li class="layui-nav-item"><a href="javascript:;" onclick="menuFire(this)" src="/index.php/admins/{$cvoo.controller}/{$cvoo.method}">{$cvoo.title}</a></li>-->
                                            <!--{/volist}-->
                                        <!--</ul>-->
                                    <!--</div>-->
                                <!--</div>-->
                        <!--<?php }else{?>-->
                        <!--<li class="layui-nav-item"><a href="javascript:;" onclick="menuFire(this)" src="/index.php/admin/{$cvo.controller}/{$cvo.method}">{$cvo.title}</a></li>-->
                        <!--<?php }?>-->
                        <!--{/volist}-->
                    <!--</ul>-->
                    <!--<?php }?>-->
                <!--</div>-->
            <!--</div>-->
            <!--{/volist}-->
            {volist name="menus" id="vo"}
            <div class="layui-colla-item">
                <h2 class="layui-colla-title"
                    {if (isset($vo['controller']) && $vo['controller'])}
                    onclick="menuFire(this)" src="__PUBLIC__/admin/{$vo.controller}/{$vo.method}"
                    {else /}
                    {/if}
                >
                {$vo.title}
                </h2>
                <div class="layui-colla-content {$i==0?' layui-show':''}">
                    <?php if(isset($vo['children']) && $vo['children']){?>
                    <ul class="layui-nav layui-nav-tree" lay-filter="test">
                        {volist name="vo.children" id="cvo"}
                        <li class="layui-nav-item"><a href="javascript:;" onclick="menuFire(this)" src="__PUBLIC__/admin/{$cvo.controller}/{$cvo.method}">{$cvo.title}</a></li>
                        {/volist}
                    </ul>
                    <?php }?>
                </div>
            </div>
            {/volist}
        </div>
    </div>
    <!--主操作页面-->
    <div class="main">
        <iframe src="__PUBLIC__/admin/Home/welcome" onload="resetMainHeight(this)" style="width: 100%;height: 100%;" frameborder="0" scrolling="0"></iframe>
    </div>
    <script>
        layui.use(['element','layer'], function(){
            var element = layui.element;
            $ = layui.jquery;
            layer = layui.layer;

            resetMenuHeight();
        });

        // 重新设置菜单容器高度
        function resetMenuHeight(){
            var height = document.documentElement.clientHeight - 50;//获取元素内容及其边框所占据的空间大小减去顶部的50像素
            $('#menu').height(height);
        }

        // 重新设置主操作页面高度
        function resetMainHeight(obj){
            var height = parent.document.documentElement.clientHeight - 53;
            //$('.main').height(height);
            $(obj).parent('div').height(height);
        }

        // 菜单点击
        function menuFire(obj){
            // 获取url
            var src = $(obj).attr('src');
            //alert(src);/index.php/admin/Admin/index
            // 设置iframe的src,将menu中的src传到中
            $('iframe').attr('src',src);//attr是jq中的属性操作方法，前面是属性，后面是参数
        }

        // 退出
        function logout(){
            layer.confirm('确定要退出吗？', {
                icon:3,
                btn: ['确定','取消']
            }, function(){
                $.get('__PUBLIC__/admin/account/logout',function(res){
                    if(res.code>0){
                        layer.msg(res.msg,{'icon':2});
                    }else{
                        layer.msg(res.msg,{'icon':1});
                        setTimeout(function(){window.location.href="__PUBLIC__/admin/account/login";},1000);
                    }
                },'json');
            });
        }
    </script>
</body>
</html>